<template>
  <div>    
    <router-view></router-view>
  </div>
</template>
<script>
export default {
  components: {},
  created() {
    this.$store.commit("INIT_USER");
    // 判断localStorage中是否有用户信息，如果没有，则跳转到登录页面
    if (localStorage.getItem("userInfo") == null) {
      this.$router.push("/login");
    }
  },
  mounted() {},
  watch: {
	
  },
  //页面渲染前的钩子函数
  beforeMount() {
    if (localStorage.getItem("userInfo") == null) {
      //弹窗提示请先登录
      this.$message({
        type: "warning",
        message: "请先登录",
        //时间

      });
    setTimeout(() =>function(){
      this.$router.push("/login");
    },1500)
    }
  },
};
</script>